@import '../variables.css';
/* stylelint-disable no-descending-specificity */

:root {
  --radio-button-size: 12px;
}

.radioButton {
  display: flex;
  flex-direction: column;

  &.marginBottom0 {
    margin-bottom: 0;
  }
}

.labelText {
  margin: 0 0 0 var(--gutter-static-one-third);
  display: flex;
  align-items: center;
  min-height: var(--control-min-size-desktop);
}

[dir="rtl"] .labelText {
  margin: 0 var(--gutter-static-one-third) 0 0;
}

.radioLabel {
  position: relative;
  line-height: var(--line-height);
  display: flex;
  align-items: baseline;
  flex-grow: 2;
  border-radius: var(--radius);
  font-size: var(--font-size-medium);
  margin-bottom: 0;
  min-height: var(--control-min-size-desktop);

  &.error {
    color: var(--error);

    &::before {
      border-color: var(--error) !important;
    }
  }
}

.labelInteractionStyles {
  composes: interactionStyles boxOffsetStartSmall boxOffsetEndSmall from "../sharedStyles/interactionStyles.css";
}

.labelFocused {
  composes: isFocused from "../sharedStyles/interactionStyles.css";
}

.labelPseudo {
  position: relative;
  width: var(--radio-button-size);
  height: var(--radio-button-size);
  border: 1px solid var(--color-border-form);
  border-radius: 999px;
  background: #fff;
  flex-shrink: 0;
  top: 1px;
}

.labelPseudo::after {
  content: '';
  width: 6px;
  height: 6px;
  background-color: #000;
  position: absolute;
  top: 2px;
  left: 2px;
  border-radius: 999px;
  transition: all 0.2s ease;
}

/**
 * Disabled or read only
 */
.disabled {
  & .radioLabel {
    cursor: default;
  }

  & .labelPseudo,
  & .input:checked + .labelPseudo {
    background-color: var(--checkable-disabled-fill);
    border-color: var(--checkable-disabled-fill);

    &::after {
      opacity: 0.5;
    }
  }
}

/**
 * Inline radio button
 */
.inline {
  display: inline-flex;

  & .radioLabel {
    align-items: center;
  }

  & .labelPseudo {
    top: 0;
  }

  & + .inline {
    margin-left: var(--gutter-static-two-thirds);
  }
}

[dir="rtl"] .inline + .inline {
  margin-right: var(--gutter-static-two-thirds);
  margin-left: 0;
}

.input {
  position: absolute;
  z-index: -1;
  clip: rect(1px, 1px, 1px, 1px);
}

.input:not(:checked) + .labelPseudo::after {
  opacity: 0;
  -webkit-transform: scale(0);
  transform: scale(0);
}

.input:checked + .labelPseudo {
  background-color: #fff;

  &::after {
    opacity: 1;
    -webkit-transform: scale(1);
    transform: scale(1);
    background-color: #000;
  }
}

/**
 * Feedback
 */
.radioFeedback {
  font-size: var(--font-size-medium);
}

.hasWarning {
  & .radioFeedback {
    color: var(--warn);
  }

  & .labelPseudo {
    border-color: var(--warn);
  }
}

.hasError {
  & .radioFeedback {
    color: var(--error);
  }

  & .labelPseudo {
    border-color: var(--error);
  }
}
